package com.zsrt.java.ex.reflect.reflect03;

import static org.junit.Assert.*;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Scanner;

import org.junit.Test;

public class DispatchController {
	
	@Test
	public void testName() throws Exception {
		doPost();
	}
	
	public void doPost() throws Exception{
		
			Scanner sn=new Scanner(System.in);
			System.out.println("输入请求：");
			String url=sn.next();
			String actions[]=url.split("-");
			Class clazz=Class.forName("com.zsrt.java.ex.reflect.reflect03."+actions[0]);
			Constructor constructor=clazz.getDeclaredConstructor();
			Object obj=constructor.newInstance();
			Method method=clazz.getDeclaredMethod(actions[1]);
			method.invoke(obj);
			
			
	
		
	}

}
